package com.jackeys.piaems.controller;

import com.jackeys.piaems.service.PaymentService;
import com.jackeys.piaems.util.StatusEnumUtil;
import com.jackeys.piaems.vo.ResponseVo;
import org.apache.juli.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @ClassName: PaymentController
 * @Description: 账单控制器
 * @Author: Jackeys
 * @Date: 2021-06-25 11:26
 * @Version: 1.0
 */
@CrossOrigin
@RestController
public class PaymentController {

    @Autowired
    private PaymentService paymentService;

    /**
     * @Name: addPayment
     * @Description: 处理用户添加账单请求
     * @Param: [userId, categoryId, date, cost, remark, flag]
     * @return: com.jackeys.piaems.vo.ResponseVo
     * @Author: Jackeys
     * @Date: 2021/6/25 11:42
     * @Version: 1.0
     */
    @RequestMapping("/payment/addPayment")
    public ResponseVo addPayment(Long userId, Long categoryId, Float cost, String remark, Integer flag) {
        return paymentService.addPayment(userId, categoryId, cost, remark, flag);
    }

    /**
     * @Name: getTotalInAndOut
     * @Description: 处理用户查询收入与支出总和的请求
     * @Param: [userId]
     * @return: com.jackeys.piaems.vo.ResponseVo
     * @Author: Jackeys
     * @Date: 2021/6/26 6:23
     * @Version: 1.0
     */
    @RequestMapping("/payment/getTotalInAndOut")
    public ResponseVo getTotalInAndOut(Long userId) {
        return paymentService.queryTotalInAndOutByUserId(userId);
    }

    /**
     * @Name: getTotalPaymentList
     * @Description: 处理用户获取账单请求
     * @Param: [userId]
     * @return: com.jackeys.piaems.vo.ResponseVo
     * @Author: Jackeys
     * @Date: 2021/6/26 11:10
     * @Version: 1.0
     */
    @RequestMapping("/payment/getTotalPaymentList")
    public ResponseVo getTotalPaymentList(Long userId, Integer page, Integer flag) {
        return paymentService.queryTotalList(userId, page, flag);
    }


    /**
     * @Name: getDetailsList
     * @Description: 处理用户获取账单详情请求
     * @Param: [userId, date, flag]
     * @return: com.jackeys.piaems.vo.ResponseVo
     * @Author: Jackeys
     * @Date: 2021/6/26 16:42
     * @Version: 1.0
     */
    @RequestMapping("/payment/getDetailsList")
    public ResponseVo getDetailsList(Long userId, Date date, Integer flag) {
        return paymentService.queryPaymentsByDate(userId, date, flag);
    }

    /**
     * @Name: deletePayment
     * @Description: 处理删除账单的请求
     * @Param: [id]
     * @return: com.jackeys.piaems.vo.ResponseVo
     * @Author: Jackeys
     * @Date: 2021/6/28 9:50
     * @Version: 1.0
     */
    @RequestMapping("/payment/deletePayment")
    public ResponseVo deletePayment(Long id) {
        return paymentService.deletePayment(id);
    }

    /**
     * @Name: updatePayment
     * @Description: 处理用户编辑账单请求
     * @Param: []
     * @return: com.jackeys.piaems.vo.ResponseVo
     * @Author: Jackeys
     * @Date: 2021/6/28 11:45
     * @Version: 1.0
     */
    @RequestMapping("/payment/updatePayment")
    public ResponseVo updatePayment(Long id,Long categoryId,Float cost,String remark,Integer flag) {
        return paymentService.updatePayment(id,categoryId,cost,remark,flag);
    }

    /**
    * @Name: getAllPayment
    * @Description: 处理用查询所有账单信息
    * @Param: [userId, flag]
    * @return: com.jackeys.piaems.vo.ResponseVo
    * @Author: Jackeys
    * @Date: 2021/6/28 22:54
    * @Version: 1.0
    */
    @RequestMapping("/payment/getAllPayment")
    public ResponseVo getAllPayment(Long userId,Integer flag){
        return paymentService.selectAllPayment(userId,flag);
    }
}
